
import 'package:chewie/chewie.dart';
import 'package:get/get.dart';
import 'package:study_demo/base/BaseController.dart';
import 'package:video_player/video_player.dart';
// import 'package:video_player_win/video_player_win.dart';

class VideoController extends BaseController {
  final initSuccess = false.obs;

  VideoPlayerController? videoPlayerController;
  ChewieController? cController;

  String url = 'http://teach.izis.cn/yz_worker/longzhu.mp4';

  @override
  void onInit() {
    super.onInit();
    videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(url))
      ..initialize().then((value) {
        initSuccess.value = true;
        // toast('初始化成功');
        cController = ChewieController(
          videoPlayerController: videoPlayerController!,
          aspectRatio: 3 / 2,
          autoPlay: true,
          looping: false,
        );
      });
  }

  @override
  void onClose() {
    super.onClose();
    videoPlayerController?.dispose();
    cController?.dispose();
  }
}
